import request from '@/axios'
import type { ApplicationOption, ApplicationTableView, ApplicationForm } from './types'


export const query = (data: PaginationRequest): Promise<PaginationResponse<ApplicationTableView>> => {
    return request.post({
        url: '/application/query',
        data
    })
}

export const get = (id: string): Promise<ApplicationForm> => {
    return request.get({
        url: `/application/${id}`
    })
}

export const add = (data: ApplicationForm): Promise<ApiResult> => {
    return request.post({
        url: '/application',
        data
    })
}

export const edit = (id: string, data: ApplicationForm): Promise<ApiResult> => {
    return request.put({
        url: `/application/${id}`,
        data
    })
}

export const remove = (id: string): Promise<ApiResult> => {
    return request.delete({
        url: `/application/${id}`
    })
}


export const getOptions = (): Promise<ApplicationOption[]> => {
    return request.get({
        url: '/application/options'
    })
}

export const tenantOptions = (): Promise<SelectOption[]> => {
    return request.get({
        url: '/application/tenant/options'
    })
}